package grouup3_project4;

import javax.swing.*;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class Student extends Person implements ActionListener
{

	public String studentID, advisor;
	private float gpa;
	static Student s;
	private JFrame frame = new JFrame("Student");
	
	public void createStudent()
	{	
		frame.setLayout(new GridLayout(8,2));
		frame.setVisible(true);
		
		frame.add(new JLabel("First Name: "));
		final JTextArea firstNameTextArea = new JTextArea(); 		
		frame.add(firstNameTextArea);
		
		frame.add(new JLabel("Last Name: "));
		final JTextArea lastNameTextArea = new JTextArea();
		frame.add(lastNameTextArea);
		
		frame.add(new JLabel("Age: "));
		final JTextArea ageTextArea = new JTextArea();
		frame.add(ageTextArea);
		
		frame.add(new JLabel("SSN: "));
		final JTextArea ssnTextArea = new JTextArea();
		frame.add(ssnTextArea);
		
		frame.add(new JLabel("Student ID: "));
		final JTextArea studentIdTextArea = new JTextArea();
		frame.add(studentIdTextArea);
		
		frame.add(new JLabel("GPA: "));
		final JTextArea gpaTextArea = new JTextArea();
		frame.add(gpaTextArea);
		
		frame.add(new JLabel("Advisor: "));
		final JTextArea advisorTextArea = new JTextArea();
		frame.add(advisorTextArea);
		
		
		
		JButton submit = new JButton("Submit");
		submit.addActionListener(new ActionListener() 
		{	
			@Override
			public void actionPerformed(ActionEvent e) 
			{
				
				int age = Integer.parseInt(ageTextArea.getText());
				float gpa = Float.parseFloat(gpaTextArea.getText());
				
				s = new Student(firstNameTextArea.getText(), lastNameTextArea.getText(), age, 
						ssnTextArea.getText(), studentIdTextArea.getText(), gpa, advisorTextArea.getText()); 			
			}
		});
		frame.add(submit);
		
		
		JButton cancel = new JButton("Cancel");
		cancel.addActionListener(new ActionListener() 
		{	
			@Override
			public void actionPerformed(ActionEvent e) 
			{
				frame.dispose(); 			
			}
		});
		
		
		frame.add(cancel);
		frame.pack();
	}
	
	
	public Student()
	{		
	}	
	public Student(String firstName, String lastName, int age, String ssn, String studentID, float gpa, String advisor)
	{
		super(firstName, lastName, age, ssn);
		this.studentID = studentID;
		this.setGpa(gpa);
		this.advisor = advisor;
		System.out.println(this);
	}
	public float getGpa() 
	{
		return gpa;
	}
	public void setGpa(float gpa) 
	{
		this.gpa = gpa;
	} 

	
	
	
	
	@Override
	public String toString()
	{
		return "First Name: " + this.firstName + "\nLastName: " + this.lastName + "\nAge: " + this.age + "\nSSN: " + this.getSsn()
				+ "\nStudent Id: " + this.studentID + "\nGPA: " + this.getGpa() + "\nAdvisor: " + this.advisor;
	}
	@Override
	public void actionPerformed(ActionEvent e) 
	{
	}
}
